<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务，帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件，不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types = 1);

namespace app\common\model\ding;

use app\common\enum\ding\Ribao as SceneEnum;
use cores\BaseModel;

/**
 * 日报模型
 * Class BalanceLog
 * @package app\common\model\user
 */
class Ribao extends BaseModel
{
    // 定义表名
    protected $name = 'ding_ribao';

    // 定义主键
    protected $pk = 'id';

    protected $updateTime = false;

    /**
     * 追加字段
     * @var array
     */
    protected $append = ['status_text'];

    public function getStatusTextAttr($value, $data)
    {

        $status = SceneEnum::data()[$data['scene']]['name'];

        return $status;
    }
   
    /**
     * 关联会员记录表
     * @return \think\model\relation\BelongsTo
     */
    public function user()
    {
        $module = self::getCalledModule();
        return $this->belongsTo("app\\{$module}\\model\\User");
    }

    /**
     * 新增记录
     * @param int $scene
     * @param array $data
     * @param array $describeParam
     */
    public static function add(int $scene, array $data, $describeParam = '')
    { //print_r(SceneEnum::data());exit;
        $model = new static;
        $model->save(array_merge([
            'scene'    => $scene,
            // 'describe' => SceneEnum::data()[$scene]['name'].','.$describeParam,
            'desc'     => $describeParam,
            'store_id' => $model::$storeId,
        ], $data));
    }

}
